#include "gtest/gtest.h"
#include "dynamic_bitset.h"

TEST(dynamic_bitset, init) 
{
	for (int l =1; l<100; l++)
	{
		dynamic_bitset  db(l);

		EXPECT_EQ (l, db.size());

		for (int i=0; i<l; i++)
		{
			EXPECT_FALSE ( db[i]);
		}
	}
}

TEST(dynamic_bitset, set_reset) 
{
	for (int l =1; l<100; l++)
	{
		dynamic_bitset  db(l);

		for (int i=0; i<l; i++)
		{
			EXPECT_FALSE ( db[i]);

			db[i] = true;
			EXPECT_TRUE ( db[i]);

			db[i] = false;
			EXPECT_FALSE ( db[i]);

		}

		for (int i=0; i<l; i++)
		{
			EXPECT_FALSE ( db[i]);
		}
	}
}

TEST(dynamic_bitset, resize)
{
	dynamic_bitset db(10);
	ASSERT_EQ(10, db.size());
	for (size_t i=0; i<10; i++)
	{
		ASSERT_FALSE(db[i]);
	}

	db.resize(20);
	ASSERT_EQ(20, db.size());
	for (size_t i=0; i<20; i++)
	{
		ASSERT_FALSE(db[i]);
	}
	for (size_t i=10; i<20; i++)
	{
		db[i]=true;
	}

	db.resize(40);
	ASSERT_EQ(40, db.size());
	for (size_t i=0; i<10; i++)
	{
		ASSERT_FALSE(db[i]);
	}
	for (size_t i=10; i<20; i++)
	{
		ASSERT_TRUE(db[i]);
	}
	for (size_t i=20; i<40; i++)
	{
		ASSERT_FALSE(db[i]);
	}
}

TEST(dynamic_bitset, resetAll)
{
	dynamic_bitset db(50);

	for (size_t i=0; i<50; i+=2)
	{
		db[i] = true;
	}

	db.reset();

	for (size_t i=0; i<50; i++)
	{
		ASSERT_FALSE(db[i]);
	}
	
}